<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>layui-demo</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/layui/css/layui.css"
	media="all">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/font-awesome-4.7.0/css/font-awesome.css" />
<!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

	<div class="page-content-wrap">
		<form class="layui-form" action="">
            
			<div class="layui-form-item" style="padding-top:30px">
				<label class="layui-form-label">用户名</label>
				<div class="layui-input-block">
					<input type="text" name="username" id="userName" lay-verify="title"
						autocomplete="off" placeholder="请输入用户名" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">单选框</label>
				<div class="layui-input-block">
					<input type="radio" name="usersex" value="男" title="男" checked="">
					<input type="radio" name="usersex" value="女" title="女">
				</div>
			</div>

			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">地址</label>
				<div class="layui-input-block">
					<textarea placeholder="请输入内容" class="layui-textarea"
						name="useraddress" id="useraddress"></textarea>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">用户电话</label>
				<div class="layui-input-block">
					<input type="text" name="usertel" id="userTel" lay-verify="title"
						autocomplete="off" placeholder="手机号码" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">等级</label>
				<div class="layui-input-block">
					<select name="userlevel" lay-filter="aihao">
						<option value="0">管理员</option>
						<option value="1">普通用户</option>

					</select>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">状态</label>
				<div class="layui-input-block">
					<select name="userstate" lay-filter="aihao">
						<option value="1">启用</option>
						<option value="0">禁用</option>
					</select>
				</div>
			</div>


			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-normal btn-update" type="button" lay-submit=""
						lay-filter="demo1">立即提交</button>
				</div>
			</div>
		</form>
	</div>

	<script src="${pageContext.request.contextPath}/layui/layui.js"
		charset="utf-8"></script>
	<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

	<script>
		layui.use('table', function() {
			var table = layui.table;

			//监听提交  新增加的代码  监听2
			layui.form.on('submit(demo1)', function(data) {

				//表单中的数据 进行转换，得到一个json格式的字符串
				console.log(JSON.stringify(data.field));
				//ajax请求实现访问控制器
				/* 	$.ajax({
						type : "put", //提交方式
						url : "${pageContext.request.contextPath}/users", ////地址和springmvc中控制器地址一致
						data : JSON.stringify(data.field), //提交给控制器的数据
						contentType : "application/json", //提交给控制的数据 格式
						success : function(cm) {
							layer.msg(cm.msg, {
								time : 2000
							//两秒延迟
							}, function() {
								if (cm.msg == "增加成功") {

								}

							});

						}
					}); */

				return false;
			});

		});
	</script>

</body>
</html>